//
//  ZDBtn.m
//  runLeg1
//
//  Created by YYKJ on 2017/4/6.
//  Copyright © 2017年 YYKJ. All rights reserved.
//

#import "ZZButton.h"

@implementation ZZButton

-(id)initWithCoder:(NSCoder *)aDecoder{
    if (self=[super initWithCoder:aDecoder]) {
        [self commonInit];
    }
    return self;
}

-(id)initWithFrame:(CGRect)frame{
    if (self=[super initWithFrame:frame]) {
        [self commonInit];
    }
    return self;
}

-(void)commonInit{
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.imageView.contentMode = UIViewContentModeScaleAspectFit;
    self.titleLabel.font = [UIFont systemFontOfSize:12];
    
    UIView * view = [[UIView alloc]init];
    view.frame = CGRectMake(0, 0, 20, 20);
    view.backgroundColor = [UIColor redColor];
    [self addSubview:view];
    view.hidden = YES;
    
}

-(CGRect)titleRectForContentRect:(CGRect)contentRect{
    CGFloat titleX = 0;
    CGFloat titleY = contentRect.size.height *0.55;
    CGFloat titleW = contentRect.size.width;
    CGFloat titleH = contentRect.size.height - titleY;
    return CGRectMake(titleX, titleY, titleW, titleH);
}

-(CGRect)imageRectForContentRect:(CGRect)contentRect{
    CGFloat imageW = CGRectGetWidth(contentRect);
    CGFloat imageH = contentRect.size.height * 0.5;
    return CGRectMake(0, 10, imageW, imageH);
}


@end
